<template>
  <div>
    <my-header :showBack="true" title="实名认证"></my-header>
    <div>
      <div class="personal_info">
        <van-cell-group>
          <van-field v-model.trim="customerPhone"  label="手机号码：" :disabled="true" />
          <van-field v-model.trim="userInfo.nick"  label="真实姓名：" :disabled="false"  placeholder="请填写真实姓名"/>
          <van-field v-model.trim="userInfo.nick"  label="身份证号：" :disabled="false"  placeholder="请填写身份证号"/>
        </van-cell-group>
      </div>
      <div class="wname_btn">
        <van-button type="primary" size="large" @click="confirm" >修改</van-button>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
import header from "@/components/header";

export default {
name: "modifyMsg",
  data() {
    return {
      userInfo:{},
      disabledInput:false,
      customerPhone:"",
      Usertype:"",
    };
  },
  components: {
    "my-header": header
  },
  created() {
    
  },
  mounted() {
    this.getUserInfo();
    console.log(this.Usertype)
  },
  methods: {
    getUserInfo() {
      //获取用户信息
      this.$ajax(this.$api.getMyInfo).then(res => {
        if (res.code == 0 && res.msg) {
          this.userInfo  = res.msg;
          localStorage.setItem("userInfo", JSON.stringify(res.msg));
          this.customerPhone=res.msg.customerPhone;
        }
      });
    },
    confirm() {
      if (this.userInfo.nick.length < 1 || this.userInfo.nick.length > 10) {
        Toast({ message: "请输入2-10位昵称", position: "bottom" });
        return;
      }
      if (!this.$validator.isIdCard(this.userInfo.customerCard)) {
        Toast({ message: "请输入正确的身份证号", position: "bottom" });
        return;
      }
      this.$ajax(this.$api.idetwalletnick, {nick:this.userInfo.nick}).then(res => {
        if (res.code == 0) {
          Toast({ message: "修改成功", position: "bottom" });
          this.goBack();
        }else{
          Toast({ message: "修改失败", position: "bottom" });
        }
      });
    },
  }
};
</script>

<style scoped>
.personal_info{
  margin: 5px 0;
}
.personal_info .btn{
  width:80%;
  background: #26a2ff;
  margin-top:50px;
  margin-left: 10%;
  box-shadow: none;
  border-radius: 5px;
  color:#fff;
  font-size:16px;
}
.modtips{padding: 10px;}
.wname_btn{box-sizing: border-box;padding: 15px 12px;}
</style>

